package m1;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.sun.org.apache.xpath.internal.functions.FuncFalse;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        //连接
        ConnectionFactory f = new ConnectionFactory();
        f.setHost("192.168.64.140");
        f.setPort(5672);
        f.setUsername("admin");
        f.setPassword("admin");
        Connection con = f.newConnection();//连接
        Channel c = con.createChannel();//通信通道


        //创建队列 helloworld
        c.queueDeclare("helloworld", false,false,false,null);
        //向helloworld 队列发送消息
        c.basicPublish("","helloworld",null,"Hello world!".getBytes("UTF-8"));


    }
}
